#!/bin/bash

BINDIR=$(cd $(dirname $0) && pwd)

. ${BINDIR}/common
. ${BINDIR}/functions

logOutput

if curl --silent --head https://github.com | grep -i "Content-Type: text/html; charset=utf-8" >/dev/null; then
	GITBRANCH=$(cd ${FPPDIR} && git branch | grep "^\*" | sed -e "s/\*\s//")

	if [ "x${FPPDIR}" = "x/opt/fpp" ]
	then
		cd ${FPPDIR} && $SUDO git fetch && $SUDO git fetch --tags -f && $SUDO git submodule foreach git fetch
	else
		cd ${FPPDIR} && sudo -u ${FPPUSER} git fetch && sudo -u ${FPPUSER} git submodule foreach git fetch
	fi

else
	echo "Can not access github, unable to fetch git updates"
fi

